package base;

public class arrary {
    public static void main(String[] args) {
        int [] arr = {1,3,5,7,9,11};
        printall(arr);
        System.out.println();
        int max = printmax(arr);
        System.out.println("max="+max);
    }
    public static void printall(int [] arr){ //打印遍历数组
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length-1){
                System.out.print(arr[i]+"]");
            }else {
                System.out.print(arr[i]+"，");
            }
        }
    }
    public static int printmax(int [] arr){  //遍历最大值
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (arr[i]>max){
                max = arr[i];
            }
        }
        return max;
    }

}
